package com.ruoyi.web.controller.blogs;

import com.ruoyi.blogs.domain.BsNoteLikeRecord;
import com.ruoyi.blogs.service.IBsNoteLikeRecordService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 赞点踩记录Controller
 *
 * @author ruoyi
 * @date 2022-10-28
 */
@RestController
@RequestMapping("/blogs/likeBelittleRecord")
public class BsLikeBelittleRecordController extends BaseController {
    @Autowired
    private IBsNoteLikeRecordService bsLikeBelittleRecordService;

    /**
     * 查询赞点踩记录列表
     */
    @PreAuthorize("@ss.hasPermi('blogs:likeBelittleRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BsNoteLikeRecord bsNoteLikeRecord) {
        startPage();
        List<BsNoteLikeRecord> list = bsLikeBelittleRecordService.selectBsNoteLikeRecordList(bsNoteLikeRecord);
        return getDataTable(list);
    }

    /**
     * 导出赞点踩记录列表
     */
    @PreAuthorize("@ss.hasPermi('blogs:likeBelittleRecord:export')")
    @Log(title = "赞点踩记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BsNoteLikeRecord bsNoteLikeRecord) {
        List<BsNoteLikeRecord> list = bsLikeBelittleRecordService.selectBsNoteLikeRecordList(bsNoteLikeRecord);
        ExcelUtil<BsNoteLikeRecord> util = new ExcelUtil<BsNoteLikeRecord>(BsNoteLikeRecord.class);
        util.exportExcel(response, list, "赞点踩记录数据");
    }

    /**
     * 获取赞点踩记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('blogs:likeBelittleRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(bsLikeBelittleRecordService.selectBsNoteLikeRecordById(id));
    }

    /**
     * 新增赞点踩记录
     */
    @PreAuthorize("@ss.hasPermi('blogs:likeBelittleRecord:add')")
    @Log(title = "赞点踩记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BsNoteLikeRecord bsNoteLikeRecord) {
        return toAjax(bsLikeBelittleRecordService.insertBsNoteLikeRecord(bsNoteLikeRecord));
    }

    /**
     * 修改赞点踩记录
     */
    @PreAuthorize("@ss.hasPermi('blogs:likeBelittleRecord:edit')")
    @Log(title = "赞点踩记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BsNoteLikeRecord bsNoteLikeRecord) {
        return toAjax(bsLikeBelittleRecordService.updateNoteBsLikeRecord(bsNoteLikeRecord));
    }

    /**
     * 删除赞点踩记录
     */
    @PreAuthorize("@ss.hasPermi('blogs:likeBelittleRecord:remove')")
    @Log(title = "赞点踩记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(bsLikeBelittleRecordService.deleteBsNoteLikeRecordByIds(ids));
    }
}
